package com.shujia.spark.core

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object Demo15Cartesian {
  def main(args: Array[String]): Unit = {

    // Cartesian 做笛卡尔积：不指定条件或者条件恒成立的关联
    val conf: SparkConf = new SparkConf()
    conf.setMaster("local")
    conf.setAppName("Demo15Cartesian")

    val sc: SparkContext = new SparkContext(conf)

    val stuRDD: RDD[String] = sc.textFile("spark/data/stu/students.txt")

    val rdd01: RDD[String] = stuRDD.sample(withReplacement = false, fraction = 0.02, seed = 111)
    rdd01.foreach(println)

    rdd01.cartesian(rdd01).foreach(println)


  }

}
